import 'package:flutter/material.dart';
import 'package:gif/gif.dart';
import 'package:lottie/lottie.dart';
import '../base/wqs_text.dart';
import 'package:ball_lion/resources/colours.dart';
import 'package:ball_lion/utils/utils.dart';

class LoadingIndicator extends StatelessWidget {
  const LoadingIndicator({super.key, this.isSilver = false});
  const LoadingIndicator.sliver({super.key}) : isSilver = true;

  final bool isSilver;

  @override
  Widget build(BuildContext context) {
    if (isSilver) {
      return SliverLayoutBuilder(
        builder: (context, constraints) => SliverToBoxAdapter(
            child: SizedBox(
          height: constraints.viewportMainAxisExtent,
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Gif(
                    image: AssetImage(Utils.getFilePath('refresh_loading.gif')),
                    width: 80,
                    height: 80,
                    autostart: Autostart.loop),
                const QsText("努力加载中", color: Colours.grey66)
              ],
            ),
          ),
        )),
      );
    } else {
      return Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Gif(
                image: AssetImage(Utils.getFilePath('refresh_loading.gif')),
                width: 60,
                height: 60,
                autostart: Autostart.loop),
            const QsText("努力加载中", color: Colours.grey66)
          ],
        ),
      );
    }
  }
}
